<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生管理</title>
<%@ include file="../../common/importLib.jsp" %>
<script type="text/javascript" src="../common/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="../common/jquery-cascade/js/jquery.cityselect.js"></script>
<!-- <script type="text/javascript" src="js/mrjy.maintain.js"></script>	 -->
<script type="text/javascript">
	/**
	 * 增删改查参数设置
	 */
	tableTitle = "学员表";
	tableURL = getTimeURL("userInfo/userList.do?roleId=4");
	toolbarView = 2;
	tableColumns = [[{field:'ck',checkbox:true},
	                {field:'id',title:'id',width:0,rowspan:1},
					{field:'opt',title:'操作',width:130,align:'center', rowspan:1,
						formatter:function(value,rowData,rowIndex){	
							var queryUrl = 'userInfo/queryById.do?id=' + rowData.id;						
							return "<a title='修改' class='xxl_linkbutton' iconCls='icon-edit' href='javascript:datagridUpdate(\"" + queryUrl + "\")'>修改</a>";
						}
					},	
	                {field:'picName',title:'照片',width:60,rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.picName==""){
								return "";
							}else{
								var url=mrjyFile+"maintain/userpic/"+rowData.picName+"?"+new Date().getTime();
								return "<img onclick=\"viewPic('"+url+"')\" src='"+url+"' style='width:50px;height:40px;'/>";
							}
						}},
					{field:'loginCode',title:'账号',width:120,rowspan:1},	
					{field:'userName',title:'姓名',width:100,rowspan:1},
					/* {field:'className',title:'班级名称',width:250,rowspan:1}, */
					{field:'sex',title:'性别',width:70,rowspan:1},
					{field:'email',title:'邮箱',width:100,rowspan:1},	
					{field:'mobilePhone',title:'手机号码',width:100,rowspan:1},
					{field:'birthday',title:'生日',width:100,rowspan:1},
					{field:'phone',title:'电话',width:100,rowspan:1},
					{field:'qq',title:'QQ',width:100,rowspan:1},	
					{field:'registerDateString',title:'注册日期',width:150,rowspan:1},
					{field:'province',title:'省份',width:70,rowspan:1},
					{field:'city',title:'城市',width:70,rowspan:1},	
					{field:'county',title:'区域',width:70,rowspan:1},
					{field:'street',title:'街道地址',width:120,rowspan:1},	
					{field:'userDesc',title:'个人简介',width:180,rowspan:1},
					{field:'roleName',title:'角色名称',width:70,rowspan:1},
					{field:'schoolName',title:'机构名称',width:150,rowspan:1},
					{field:'disableFlag',title:'禁用状态',width:80,align:'center', rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.disableFlag == 0){
								return "<font color='green'>起用</font>";
							}else{
								return "<font color='red'>禁用</font>";
							}
						}
					}]];
	
	var addWidth = 700; //添加窗口宽度
	var addHeight = 350; //添加窗口高度
	var addTitle = "添加学员"; //添加标题
	var updateWidth = 700; //修改窗口宽度
	var updateHeight = 450; //修改窗口高度
	var updateTitle = "修改学员信息"; //修改标题
	var updateDisableFlagUri = "userInfo/updateDisableFlag.do"; //禁用、起用记录
	var deleteUri = "userInfo/deleteByIds.do"; //删除记录
	
	/**
	 * 初始化添加表单
	 */	
	function initAddForm(){	
		//openPicUpload();
		$("#roleId").val("4");
		addFormProcess("loginCode","用户",true);	
		ajaxFormValidator("loginCode","账号",1,16,"userInfo/loginCodeValidate.do","ascii");
		ajaxFormValidator("mobilePhone","手机",11,11,"userInfo/mobilePhoneValidate.do");
		baseFormValidator("userName","姓名",2,12,"chinese");
		//baseFormValidator("mobilePhone","电话",11,11,"mobile");
	}
	
	/**
	 * 初始化修改表单
	 */
	function initUpdateForm(jsonObject){
		selectRadio(jsonObject.sex,"datagrid_update");
		$("#picNameUpdate").val(jsonObject.picName);
		openPicUploadUpdate();
		$("#roleIdUpdate").val("4");
		$("#loginCodeUpdate").html(jsonObject.loginCode);
		$("#userNameUpdate").val(jsonObject.userName);
		$("#idUpdate").val(jsonObject.id);
		$("#emailUpdate").val(jsonObject.email);
		$("#mobilePhoneUpdate").val(jsonObject.mobilePhone);
		$("#birthdayUpdate").val(jsonObject.birthday);
		$("#phoneUpdate").val(jsonObject.phone);
		$("#qqUpdate").val(jsonObject.qq);
		$("#streetUpdate").val(jsonObject.street);
		$("#userDescUpdate").val(jsonObject.userDesc);
		$("#streetUpdate").val(jsonObject.street);		
		//$("#city_4Update").citySelect({prov:jsonObject.province, city:jsonObject.city, dist:jsonObject.county});
		updateFormProcess("userName","用户");	
		baseFormValidator("userNameUpdate","姓名",2,12,"chinese");
		baseFormValidator("mobilePhoneUpdate","电话",11,11,"mobile");
	}
	
	/**
	 *打开照片上传组件
	 */
	function openPicUpload(){
		uploadOneFile("uploadFile","/mrjy_file/common/util/upload.do","1000KB",100,30,"uploadMessage","backup/maintain/userpic/","picName");
	}
	function openFileUpload(){
		uploadOneFile("uploadFileImport","/mrjy_file/common/util/upload.do","20000KB",100,30,"uploadMessageImport","backup/maintain/userxls/","fileName");
	}
	/**
	 *打开修改照片上传组件
	 */
	function openPicUploadUpdate(){
		uploadOneFile("uploadFileUpdate","/mrjy_file/common/util/upload.do","1000KB",100,30,"uploadMessageUpdate","backup/maintain/userpic/","picNameUpdate");
	}
	
	function ajaxLoading(){   
	    $("<div class=\"datagrid-mask\"></div>").css({display:"block",width:"100%",height:600}).appendTo("#datagrid_import");   
	    $("<div class=\"datagrid-mask-msg\"></div>").html("正在处理，请稍候。。。").appendTo("#datagrid_import").css({display:"block",left:(850 - 190) / 2,top:(600 - 45) / 2});   
	 }   
	 function ajaxLoadEnd(){   
	     $(".datagrid-mask").remove();   
	     $(".datagrid-mask-msg").remove();               
	}   
</script>
<script type="text/javascript">

</script>
</head>
<body id="layout" class="easyui-layout">

	<div style="background: none repeat scroll 0% 0% #EFEFEF; height:75px; padding: 6px 2px; border-bottom: 1px solid #CCC;"
		region="north"  split="false" title="条件查询">
	<form  id="searchForm" >
	<table>
		
		<tr>
			<td>学员名字：</td><td><input type="text" name="userName"/> </td>					
			<td>学员账号：</td><td><input type="text" name="loginCode"/> </td>	
			<td>学员手机：</td><td><input type="text" name="mobilePhone"/> </td>					
			<td><a class="easyui-linkbutton" id="search" iconCLs="icon-search"  onclick="searchTable()">搜索</a></td>
			<td><a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('searchForm').reset();reload();">清空</a></td>
			<td width="50px;"></td>			
			<!-- <td colspan="2"><a class="easyui-linkbutton" id="search" iconCls="icon-add" onclick="openImport()">批量导入学生信息</a></td> -->
		</tr>
	
	</table>
	</form>
	</div>
	<div region="center">
	<!-- datagrid信息表 -->
	<table id="datagrid_table"></table>
	<!-- 添加记录 -->
	<div id="datagrid_add">
		<form id="add_form" action="userInfo/maintainAddUserInfo.do" method="post">			
			<input type ="hidden" id="roleId" name="roleId">
			<table width="630" class="xxl_tb_1">
				<tbody>	
					<tr>
						<td width="120" class="xxl_td_2">账号：</td>
						<td ><input type="text" id="loginCode" name="loginCode" onchange="validateSubmitOnce=true"/></td>
						<td><div id="loginCodeTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">姓名：</td>
						<td><input type="text" id="userName" name="userName"/></td>
						<td><div id="userNameTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">手机号码：</td>
						<td><input type="text" id="mobilePhone" name="mobilePhone" maxlength="11" onchange="validateSubmitOnce=true"/></td>
						<td><div id="mobilePhoneTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2"></td>
						<td><div style="width:250px;color: red">*学生的默认密码是：123abc</div></td>
						<td></td>
					</tr>
					<tr>
						<td colspan="3" style="text-align: center">					
							<a class="easyui-linkbutton" iconCls="icon-ok" onclick="$('#add_form').submit();">添加</a>
							<a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('add_form').reset()">重置</a>
							<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#datagrid_add').window('close');">取消</a>
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
	<!-- 批量添加记录 -->
	<div id="datagrid_import"  style="display: none">
		<form id="import_form" action="/maintain/signUpInfo/batchAddSignUpInfo.do" method="post">
		<img src="../../common/images/Student_step_04.png" width="100%" height="43" id="uploadStatus">
		<input type="hidden" id="fileName" name="fileName" onclick='openFileUpload()'>
		<div id="titleTip" style="width:250px;clear: both;"></div>			
		<div id="messageSpan" style="font-family:微软雅黑;font-size:16px;font-weight:bold;color:#FF3366">${message}</div>
		<div id="first">
			<table width="730" class="xxl_tb_1" align="center">
				<tbody>	
					<tr>
						<td  class="xxl_td_2" width="320">学校名称：</td>
						<td ><input type="text" id="subIdImport" /></td>
					</tr>
					<tr>
						<td class="xxl_td_2">班级：</td>
						<td><input type="text" id="classIdImport" name="classIdImport"/></td>
					</tr>
					<tr>
						<td class="xxl_td_2">文件：</td>
						<td>
							<input id='uploadFileImport' type='file' name='uploadFileImport'/><span id='uploadMessageImport'></span>
						</td>
					</tr>
					<tr>
						<td></td>
						<td><a class="easyui-linkbutton" iconCls="icon-ok" onclick="javascript:queryUploadUserInfo()">下一步</a>&nbsp;&nbsp;&nbsp;  <a href="/xxl/common/moxls/student_new.xls" >下载模板</a></td>
					</tr>
				</tbody>
			</table>
	    </div>
	    <div id="second" style="display:none">
			<table width="730" id="userInfoList" class="xxl_tb_1" align="center" cellspacing=0 cellpadding=0 border='1' align='center' style="text-align: center; font-family:'宋体'">
			
			</table>
			<div style="text-align: center;">
				<a id="secondSave" class="easyui-linkbutton" iconCls="icon-ok" onclick="javascript:submitForm()">录入</a>
				<a class="easyui-linkbutton" iconCls="icon-ok" onclick="javascript:reUpload()">重新上传</a>
			</div>
	    </div>
	     <div id="three" style="display:none">
			<table width="730" id="userList" class="xxl_tb_1" align="center" cellspacing=0 cellpadding=0 border='1' align='center' style="text-align: center; font-family:'宋体'">
			
			</table>
			<div style="text-align: center;">
				<a class="easyui-linkbutton" iconCls="icon-ok" onclick="exportExcl()">导出学生名单</a>
			</div>
	    </div>
	    </form>
		
	</div>
	<!-- 修改记录 -->
	<div id="datagrid_update">
		<form id="update_form" action="userInfo/updateById.do" method="post">
			<input type="hidden" id="idUpdate" name="id"/>
			<!-- <input type ="hidden" id="roleIdUpdate" name="roleId"> -->
			<input type="hidden" id="picNameUpdate" name="picName" onclick='openPicUploadUpdate()'>
			<table width="630" class="xxl_tb_1">
				<tbody>
					<tr>
						<td class="xxl_td_2">账号：</td>
						<td colspan="2" id="loginCodeUpdate"></td>
					</tr>
				
					<tr height="40">
						<td class="xxl_td_1">角色：</td>
						<td colspan="2">
						   <select id="roleIdUpdate" name="roleId">
						   		<option value=2>讲师</option>
						   		<option value=4>学员</option>
						   </select>
						</td>
					</tr>
					<tr>
						<td class="xxl_td_2">姓名：</td>
						<td><input type="text" id="userNameUpdate" name="userName"/></td>
						<td><div id="userNameUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr height="40">
						<td class="xxl_td_1">上传照片：</td>
						<td colspan="2"><input id='uploadFileUpdate' type='file' name='uploadFile'/><span id='uploadMessageUpdate' style='margin-left:10px'></span></td>	
					</tr>
					<tr>
						<td class="xxl_td_2">邮箱：</td>
						<td><input type="text" id="emailUpdate" name="email" onchange="validateSubmitOnce=true"/></td>
						<td><div id="emailUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">手机号码：</td>
						<td><input type="text" id="mobilePhoneUpdate" name="mobilePhone" maxlength="11"/></td>
						<td><div id="mobilePhoneUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">固定电话：</td>
						<td><input type="text" id="phoneUpdate" name="phone"/></td>
						<td><div id="phoneUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">性别：</td>
						<td><input name="sex" type="radio" value="男" class="radio-option"/>男
							<input name="sex" type="radio" value="女" class="radio-option"/>女</td>
						<td></td>
					</tr>
					<tr>
						<td class="xxl_td_2">生日：</td>
						<td><input type="text" id="birthdayUpdate" name="birthday" onClick="WdatePicker()"/></td>
						<td></td>
					</tr>
					<tr>
						<td class="xxl_td_2">QQ：</td>
						<td><input type="text" id="qqUpdate" name="qq" maxlength="10"/></td>
						<td><div id="qqUpdateTip" style="width:250px"></div></td>
					</tr>
					<!-- <tr>
						<td  class="xxl_td_2">学校地址：</td>
						<td ><div id="city_4Update">
								<select class="prov" name="province" id="province"></select> 
								<select class="city" disabled="disabled" name="city" id="city"></select>
								<select class="dist" disabled="disabled" name="county" id="county"></select>
							</div>
						</td>
						<td ></td>
					</tr>				
					<tr>
						<td class="xxl_td_2">街道地址：</td>
						<td><input type="text" id="streetUpdate" name="street"/></td>
						<td></td>
					</tr> -->
					<tr>
						<td class="xxl_td_2">个人介绍：</td>
						<td><textarea id="userDescUpdate" name="userDesc" cols="30"></textarea></td>
						<td><div id="userDescUpdateTip" style="width:250px"></div></td>
					</tr>
					
					<tr>
						<td colspan="3" style="text-align: center">
							<a class="easyui-linkbutton" iconCls="icon-ok" onclick="$('#update_form').submit();">修改</a>		
							<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#datagrid_update').window('close');">取消</a>
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
	</div>

</body>
</html>